package com.lovo.addressbook;

import java.util.List;

import junit.framework.TestCase;

public class PropertiesUtilTest extends TestCase {
	private PropertiesUtil pUtil;
	private User [] users;
	protected void setUp() throws Exception {
		super.setUp();
		TestUtil.initialConfig();
		pUtil = new PropertiesUtil("config/telephone.dat");
		users = TestUtil.getUsers();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}
/*
	public void testPropertiesUtil() {
		PropertiesUtil pUtil = new PropertiesUtil("c:/users/song/");
	}
*/
	public void testGetUsers() {
		List<User> actualUsers = pUtil.getUsers();
		for (int i = 0; i != users.length; ++i) {
			TestUtil.assertMatch(users[i], actualUsers.get(i));
		}
	}

	public void testSave() {
		pUtil.save(TestUtil.getUser());
		List<User> actualUsers = pUtil.getUsers();
		TestUtil.assertMatch(actualUsers.get(actualUsers.size() - 1), TestUtil.getUser());
	}

}
